package beans;

import java.util.Set;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import modelo.Perfil;

@ManagedBean
@RequestScoped
// public class SeleccionPerfilBean implements ActionListener,ValueChangeListener {
public class SeleccionPerfilBean {

	@ManagedProperty(value="#{loginBean}")
	private LoginBean loginBean;

	private Perfil selectedPerfil;
	private Perfil selected;
	private Set<Perfil> perfiles;
	
	public Perfil getSelectedPerfil() {
		return selectedPerfil;
	}
	public void setSelectedPerfil(Perfil selectedPerfil) {
		this.selectedPerfil = selectedPerfil;
	}	
	public LoginBean getLoginBean() {
		return loginBean;
	}
	public void setLoginBean(LoginBean loginBean) {
		this.loginBean = loginBean;
	}
	
	@PostConstruct
	public void init(){
		
		Set<Perfil> perf = (Set<Perfil>) loginBean.getObjUsuario().getPerfiles();
		setPerfiles(perf);
	}
	
	public String enviarPerfil(){
		System.out.println("exito" + selected.getNombre());
		loginBean.setObjPerfil(selected);
		return "exito" + selected.getNombre();
	}
	public Perfil getSelected() {
		return selected;
	}
	public void setSelected(Perfil selected) {
		this.selected = selected;
	}
	public Set<Perfil> getPerfiles() {
		return perfiles;
	}
	public void setPerfiles(Set<Perfil> perfiles) {
		this.perfiles = perfiles;
	}

}
